package JFrame.Admin.MailManager;

import Dao.MailDaoImpl;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @className: AdminModifJFrame
 * @description: TODO 类描述
 * @author: Dong
 * @date: 2021/12/29
 **/
public class ModifyMailJFrame extends JFrame {
    private JLabel l_id,l_uid, l_arrivalTime, l_mailState, l_completionTime, l_mailName;
    private JTextField t_id,t_uid, t_arrivalTime, t_mailState, t_completionTime, t_mailName;
    private JPanel jPanel;
    private JButton button_qd;
    public ModifyMailJFrame() {
        this.setTitle("修改快件窗体");
        this.setBounds(100, 100, 350, 650);
        init();
        this.setLocationRelativeTo(null);//窗体居中显示
        this.setVisible(true);

    }

    private void init() {
        this.setLayout(null);
        jPanel = (JPanel) this.getContentPane();
        t_id = new JTextField();
        t_uid= new JTextField();
        t_arrivalTime = new JTextField();
        t_mailState = new JTextField();
        t_completionTime = new JTextField();
        t_mailName = new JTextField();

        l_id = new JLabel("输入修改快件的id");
        l_uid = new JLabel("输入新的用户id");
        l_arrivalTime = new JLabel("输入修改新的到站时间");
        l_mailState = new JLabel("输入新的派送状况");
        l_completionTime = new JLabel("输入新的完成时间");
        l_mailName = new JLabel("输入新的快件名称");


        button_qd = new JButton("确定");
        button_qd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new MailDaoImpl().UpData(t_uid.getText(),t_id.getText(),t_arrivalTime.getText(),t_mailState.getText(),t_completionTime.getText(),t_mailName.getText());
            }
        });
        button_qd.setBounds(120,430,100,50);
        button_qd.setBackground(new Color(196, 210, 245));

        addCom(l_id,l_uid, l_arrivalTime, l_mailState, l_completionTime, l_mailName, t_id,t_uid, t_arrivalTime,
                t_mailState, t_completionTime, t_mailName,button_qd);
        setBound1(l_id,l_uid, l_arrivalTime, l_mailState, l_completionTime, l_mailName);
        setBound2(t_id,t_uid, t_arrivalTime, t_mailState, t_completionTime, t_mailName);

    }

    private void addCom(Component... components) {
        for (Component component : components) {
            jPanel.add(component);
        }
    }

    private void setBound1(Component... components) {
        int i = 0;
        for (Component component : components) {
            component.setBounds(10, 50 + i, 180, 30);
            i += 60;
        }
    }

    private void setBound2(Component... components) {
        int i = 0;
        for (Component component : components) {
            component.setBounds(150, 50 + i, 180, 30);
            i += 60;
        }
    }


}
